package com.easy.order.controller;

import com.easy.common.bean.OrderItems;
import com.easy.common.service.IOrderService;
import com.easy.common.util.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("orderitems")
public class OrderItemsController {
    @Autowired
    IOrderService orderService;

    @PostMapping("/")
    public ResultData insert(@RequestBody OrderItems orderItems) {
        OrderItems data=orderService.insertItem(orderItems);
        return ResultData.success(data);
    }
    @PutMapping("/")
    public ResultData update(@RequestBody OrderItems orderItems) {
        OrderItems data=orderService.updateItem(orderItems);
        return ResultData.success(data);
    }
    @DeleteMapping("/{id}")
    public ResultData delete(@PathVariable Integer id) {
        int result=orderService.deleteItem(id);
        if(result>=1){
            return ResultData.success("200","删除成功",null);
        }else{
            return ResultData.fail();
        }
    }
}
